package com.atguigu.spring.entity;

import jakarta.validation.Valid;
import jakarta.validation.constraints.*;

import java.time.LocalDate;
import java.util.List;

public class User {

    @NotNull(message = "ID 不能为空")
    private Long id;

    @NotBlank(message = "姓名不能为空")
    @Size(min = 3, max = 5, message = "姓名长度需在 3-5 之间")
    private String name;

    @Email(message = "邮箱格式不正确")
    private String email;

    @Positive(message = "年龄必须为正数")
    @Max(value = 150, message = "年龄不能超过 150")
    private Integer age;

    @Past(message = "生日必须为过去的日期")
    private LocalDate birthday;

    @NotEmpty(message = "爱好不能为空")
    private List<String> hobbies;

    @Valid // 级联校验嵌套对象
    private Address address;

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", email='" + email + '\'' +
                ", age=" + age +
                ", birthday=" + birthday +
                ", hobbies=" + hobbies +
                ", address=" + address +
                '}';
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
    }

    public List<String> getHobbies() {
        return hobbies;
    }

    public void setHobbies(List<String> hobbies) {
        this.hobbies = hobbies;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public User(Long id, String name, String email, Integer age, LocalDate birthday, List<String> hobbies, Address address) {
        this.id = id;
        this.name = name;
        this.email = email;
        this.age = age;
        this.birthday = birthday;
        this.hobbies = hobbies;
        this.address = address;
    }

    public User() {
    }
}
